//
//  FKTabBarVC.m
//  NeteaseEdu
//
//  Created by Frank.Chan on 16/9/26.
//  Copyright © 2016年 zmosa. All rights reserved.
//

#import "FKTabBarVC.h"
#import "FKProfileVC.h"
#import "FKAllCourseVC.h"
#import "FKHomeVC.h"
#import "FKNavVC.h"

@interface FKTabBarVC ()

@end

@implementation FKTabBarVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor redColor];
    
    [self addChildVCs];
    self.tabBar.backgroundColor = [UIColor whiteColor];
}

- (void)addChildVCs
{
    FKHomeVC *homeVC = [[FKHomeVC alloc] init];
    [self addChildVC:homeVC title:@"首页" imageName:@"tab-recommend_28x22_" selectedImageName:@"tab-recommend-hl_28x22_"];
    
    FKAllCourseVC *allCourseVC = [[FKAllCourseVC alloc] init];
    [self addChildVC:allCourseVC title:@"全部课程" imageName:@"tab-allcourse_28x22_" selectedImageName:@"tab-allcourse-hl_28x22_"];
    
    FKProfileVC *profileVC = [[FKProfileVC alloc] init];
    [self addChildVC:profileVC title:@"我的学习" imageName:@"tab-mystudy_28x22_" selectedImageName:@"tab-mystudy-hl_28x22_"];
}

- (void)addChildVC:(UIViewController *)childVC title:(NSString *)title imageName:(NSString *)imageName selectedImageName:(NSString *)selectedImageName
{
    childVC.title = title;
    childVC.tabBarItem.image = [[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    childVC.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    // 设置tabbar普通状态下的文字样式
    NSDictionary *normalTextAttrs = @{NSForegroundColorAttributeName : fk_tabBarNormalColor,
                                      NSFontAttributeName : [UIFont systemFontOfSize:12]};
    [childVC.tabBarItem setTitleTextAttributes:normalTextAttrs forState:UIControlStateNormal];
    // 设置tabbar选中状态下的文字样式
    NSDictionary *selectedTextAttrs = @{NSForegroundColorAttributeName : fk_tabBarSelectedColor,
                                      NSFontAttributeName : [UIFont systemFontOfSize:12]};
    [childVC.tabBarItem setTitleTextAttributes:selectedTextAttrs forState:UIControlStateSelected];
    
    FKNavVC *nav = [[FKNavVC alloc] initWithRootViewController:childVC];
    [self addChildViewController:nav];
}

@end
